extends StateBase


@export var funnelCount = 5
@export var bornInterval = 0.3

@onready var funnelBornTimer:Timer = $FunnelBornTimer

var ownerNode:Boss01
var funnelCounter = 0


func enter(obj):
	ownerNode = obj
	funnelCounter = 0
	
	funnelBornTimer.wait_time = 0.3
	funnelBornTimer.timeout.connect(onBorn)
	funnelBornTimer.start()
	

func exit(obj):
	funnelBornTimer.stop()
	funnelBornTimer.timeout.disconnect(onBorn)


func run(delta, obj):
	pass


func onBorn():
	var funnel:Funnel = Global.createSceneInst("Funnel")
	get_tree().current_scene.add_child(funnel)
	funnel.position = ownerNode.global_position
	
	funnelCounter += 1
	
	if funnelCounter > 4:
		ownerNode.stateMachine.removeState(name, ownerNode)
